using System;
using System.Globalization;
using TelerikMvcGridCustomBindingHelper.Mapper;

namespace ExampleWebApplication.Infraestruture
{
    public class DecimalValueResolver : IValueResolver
    {
        public object Resolve(ResultContext source)
        {
            // This will preserve precision in large numbers
            var s = ((double)source.Value).ToString("R");
            var d = Decimal.Parse(s, NumberStyles.Currency);
            return d;
        }
    }

    public class GlobalDecimalValueResolver : GlobalValueResolver<double, decimal?>
    {
        protected override decimal? ResolveCore(double source)
        {
            // This will preserve precision in large numbers
            var s = source.ToString("R");
            var d = Decimal.Parse(s, NumberStyles.Currency);
            return d;
        }
    }
}